package com.tron.dobest.dynamicdatasource;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * 描述：启用aop切换数据源的条件
 *
 * @author TRON
 * @since 2020-04-29
 */
public class MyDataSourceCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        if ("true".equals(context.getEnvironment().getProperty("switchDataSourceByAop"))) {
            System.out.println("===========switchDataSourceByAop:true===========");
            return true;
        }
        return false;
    }
}
